<link rel="stylesheet" href="${request.contextPath}/static/oms/iframe/plugins/jquery-inputmail/css/jquery.inputmail.css" type="text/css">
<div class="row">
	<div class="col-md-12">
		<form id="edit-form" class="form-horizontal" action="${request.contextPath}/oms/ucenter/member/update" method="post" onsubmit="return false">
			<input type="hidden" id="id" name="id" value="${member.id}">
			<div class="box-body" >
				<div class="form-group">
					<label for="member-username" class="col-sm-2 control-label">用户名</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" name="username" id="member-username" value="${member.username}" placeholder="输入用户名...">
					</div>
					<label for="member-password" class="col-sm-2 control-label" >密码</label>
					<div class="col-sm-4">
						<input type="password" class="form-control" name="password" id="member-password" placeholder="输入密码...">
					</div>
				</div>
				<div class="form-group">
					<label for="member-email" class="col-sm-2 control-label">邮箱</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" name="email" id="member-email" value="${member.email}" placeholder="输入邮箱...">
						<ul class="input-mail-select">
							<li email="">请选择邮箱类型</li>
							<li email=""></li>
							<li email="@sina.com"></li>
							<li email="@163.com"></li>
							<li email="@qq.com"></li>
							<li email="@hotmail.com"></li>
							<li email="@126.com"></li>
							<li email="@gmail.com"></li>
							<li email="@yahoo.com"></li>
						</ul>
					</div>
					<label for="member-phone" class="col-sm-2 control-label">手机号</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" name="phone" id="member-phone" value="${member.phone}" placeholder="输入手机号...">
					</div>
				</div>
				<div class="form-group">
					<label for="member-nickname" class="col-sm-2 control-label">用户昵称</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" name="nickname" id="member-nickname" value="${member.nickname}" placeholder="输入真实姓名...">
					</div>
					<label for="member-gender" class="col-sm-2 control-label" >性别</label>
					<div class="col-sm-4">
						<select class="form-control" id="member-gender"  name="gender" style="width: 100%;">
						</select>
					</div>
				</div>
				<div class="form-group">
					<label for="member-birthday" class="col-sm-2 control-label">出生日期</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" name="birthday" id="member-birthday"  value="${(member.birthday?string('yyyy/MM/dd'))!}"  placeholder="输入出生日期...">
					</div>
					<label for="member-age" class="col-sm-2 control-label" >年龄</label>
					<div class="col-sm-4">
						<input type="number" class="form-control" name="age" id="member-age" value="${member.age}" placeholder="输入年龄...">
					</div>
				</div>
				<div class="form-group">
					<label for="member-signature" class="col-sm-2 control-label" >个性签名</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" name="signature" id="member-signature" value="${member.signature}" placeholder="输入个性签名...">
					</div>
				</div>
				<div class="form-group">
					<label  for="member-email-verify-status" class="col-sm-2  control-label">是否验证邮箱</label>
					<div class="col-sm-4">
						<select class="form-control" id="member-email-verify-status"  name="emailVerifyStatus" style="width: 100%;">
						</select>
					</div>
					<label  for="member-phone-verify-status" class="col-sm-2  control-label">是否验证手机号</label>
					<div class="col-sm-4">
						<select class="form-control" id="member-phone-verify-status"  name="phoneVerifyStatus" style="width: 100%;">
						</select>
					</div>
				</div>
				<div class="form-group">
					<label  for="member-realname-verify-status" class="col-sm-2  control-label">是否实名认证</label>
					<div class="col-sm-4">
						<select class="form-control" id="member-realname-verify-status"  name="realnameVerifyStatus" style="width: 100%;">
						</select>
					</div>
					<label  for="member-video-verify-status" class="col-sm-2  control-label">是否视频认证</label>
					<div class="col-sm-4">
						<select class="form-control" id="member-video-verify-status"  name="videoVerifyStatus" style="width: 100%;">
						</select>
					</div>
				</div>
				<div class="form-group">
					<label  for="member-status" class="col-sm-2  control-label">状态</label>
					<div class="col-sm-4">
						<select class="form-control" id="member-status"  name="status" style="width: 100%;">
						</select>
					</div>
				</div>
				<div class="form-group">
					<label for="member-description" class="col-sm-2 control-label" >描述</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" name="description" id="member-description" value="${member.signature}"  placeholder="输入描述...">
					</div>
				</div>
				<div class="form-group">
					<label for="member-remark" class="col-sm-2 control-label">备注</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" name="remark" id="member-remark" value="${member.remark}"  placeholder="输入备注...">
					</div>
				</div>
				<div class="error-message text-center">
					<span class="error-icon"></span>
					<span class="error-msg" ></span>
				</div>
			</div>
			<div class="box-footer">
				<div class="pull-right">
               		<button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 更新</button>
               		<button type="button" class="btn btn-default btn-sm" data-dismiss="modal"><i class="fa fa-close"></i> 关闭</button>
				</div>
          	</div>
		</form>
	</div>
</div>
<script type="text/javascript" src="${request.contextPath}/static/oms/iframe/plugins/jquery-inputmail/js/inputmail.js"></script>
<script type="text/javascript">
function ajaxSubmit(form) {
	var $form = $(form);
	if ($form.length === 1 && $form.validate()) {
        $.ajax({
            type: 'post',
            url: form.action,
            dataType: "json",
            data: $form.serialize()
        }).done(function(result){
            if (result.success) {
                $("#lgModal").modal('hide');
                alertMsg(result.message,"success");
                dataGridReload();
            } else {
                $form.find(".error-msg").show();
                $form.find(".error-msg").html(result.message);
            }
        });
	}
}

$(function() {
    $("#member-gender").select2({
        data: SexStore,
        placeholder: "请选择性别...",
        language: "zh-CN",
        theme: "bootstrap",
        minimumResultsForSearch: Infinity
    }).val('${member.gender}').trigger("change");
    $("#member-email-verify-status").select2({
        data: WhetherStore,
        placeholder: "请选择...",
        language: "zh-CN",
        theme: "bootstrap",
        minimumResultsForSearch: Infinity
    }).val('${member.emailVerifyStatus}').trigger("change");
    $("#member-phone-verify-status").select2({
        data: WhetherStore,
        placeholder: "请选择...",
        language: "zh-CN",
        theme: "bootstrap",
        minimumResultsForSearch: Infinity
    }).val('${member.phoneVerifyStatus}').trigger("change");
    $("#member-realname-verify-status").select2({
        data: WhetherStore,
        placeholder: "请选择...",
        language: "zh-CN",
        theme: "bootstrap",
        minimumResultsForSearch: Infinity
    }).val('${member.realnameVerifyStatus}').trigger("change");
    $("#member-video-verify-status").select2({
        data: WhetherStore,
        placeholder: "请选择...",
        language: "zh-CN",
        theme: "bootstrap",
        minimumResultsForSearch: Infinity
    }).val('${member.videoVerifyStatus}').trigger("change");
    $("#member-status").select2({
        data: StatusStore,
        placeholder: "请选择...",
        language: "zh-CN",
        theme: "bootstrap",
        minimumResultsForSearch: Infinity
    }).val('${member.status}').trigger("change");

    $.datetimepicker.setLocale('ch');
    //初始化时间选择器
    $('[name=birthday]').datetimepicker({
        format:"Y/m/d",      //格式化日期
        timepicker:true,    //开启时间选项
        yearStart:2000,     //设置最小年份
        yearEnd:2050,        //设置最大年份
        todayButton:false,    //关闭选择今天按钮
        defaultDate : new Date() //还可以是时间字符串，当前日期对应的时间数值
    });
    $('[name=email]').changeTips({
        divTip:".input-mail-select"
    });

	var $editForm = $("#edit-form");
	$editForm.validate({
        rules: {
            username: {
                required: true
            },
            password: {
                required: true
            },
            birthday: {
                required: true
            },
            email:{
                pattern: /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/
            }
        },
        messages: {
            username:{
                required:"用户名不能为空！"
            },
            password:{
                required:"密码不能为空！"
            },
            birthday: {
                required:"出生日期不能为空！"
            },
            email: {
                pattern: "邮箱格式错误！"
            }
        },
		submitHandler:ajaxSubmit,
		errorLabelContainer:".error-msg",
		wrapper:"li",
		showErrors:function(errorMap,errorList) {
			if(errorList.length>0){
				$editForm.find(".error-msg").html(errorList[0].message);
			}else{
				$editForm.find(".error-msg").html("");
			}
		},
		onkeyup: false
	});
});
</script>